//
//  EFSModel.m
//  EFSMobile
//
//  Created by cao jun on 15/11/20.
//  Copyright © 2015 Elephants Financial Service. All rights reserved.
//

#import "EFSModel.h"

@implementation EFSModel
- (NSDictionary *)dictionaryValue {
    NSDictionary *originalDictValue = [super dictionaryValue];
    NSMutableDictionary *dictValue = [originalDictValue mutableCopy];
    for (NSString *key in originalDictValue) {
        if ([self valueForKey:key] == nil) {
            [dictValue removeObjectForKey:key];
        }
    }
    return [dictValue copy];
}

+ (MTLValueTransformer *)MTTimestampToDateTransformer
{
    return [MTLValueTransformer reversibleTransformerWithForwardBlock:^(NSNumber *timestamp) {
        return [NSDate dateWithTimeIntervalSince1970: timestamp.longLongValue / 1000];
    } reverseBlock:^(NSDate *date) {
        return [date timeIntervalSince1970InMillionSecond];
    }];
}

@end
